<template>
  <div class="game-nav" :class="{ 'nav-expanded': isExpanded }">
    <div class="nav-toggle" @click="toggleNav">
      <span class="toggle-icon">{{ isExpanded ? '✕' : '≡' }}</span>
    </div>
    
    <div class="nav-content">
      <!-- 社交功能 -->
      <div class="nav-section">
        <h3>社交</h3>
        <button @click="navigateTo('/friends')">
          <span class="icon">👥</span>
          <span class="text">好友</span>
        </button>
        <button @click="navigateTo('/market')">
          <span class="icon">🏪</span>
          <span class="text">市场</span>
        </button>
        <button @click="navigateTo('/collaboration')">
          <span class="icon">🤝</span>
          <span class="text">合作</span>
        </button>
      </div>

      <!-- 季节系统 -->
      <div class="nav-section">
        <h3>季节</h3>
        <button @click="navigateTo('/season')">
          <span class="icon">🌸</span>
          <span class="text">季节信息</span>
        </button>
        <button @click="navigateTo('/events')">
          <span class="icon">🎉</span>
          <span class="text">活动</span>
        </button>
      </div>

      <!-- 宠物系统 -->
      <div class="nav-section">
        <h3>宠物</h3>
        <button @click="navigateTo('/pets')">
          <span class="icon">🐕</span>
          <span class="text">我的宠物</span>
        </button>
      </div>

      <!-- 小游戏 -->
      <div class="nav-section">
        <h3>游戏</h3>
        <button @click="navigateTo('/games')">
          <span class="icon">🎮</span>
          <span class="text">小游戏</span>
        </button>
      </div>

      <!-- 加工系统 -->
      <div class="nav-section">
        <h3>加工</h3>
        <button @click="navigateTo('/processing')">
          <span class="icon">🏭</span>
          <span class="text">加工中心</span>
        </button>
        <button @click="navigateTo('/recipes')">
          <span class="icon">📖</span>
          <span class="text">配方</span>
        </button>
      </div>

      <!-- 任务系统 -->
      <div class="nav-section">
        <h3>任务</h3>
        <button @click="navigateTo('/quests')">
          <span class="icon">📋</span>
          <span class="text">任务</span>
        </button>
        <button @click="navigateTo('/achievements')">
          <span class="icon">🏆</span>
          <span class="text">成就</span>
        </button>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { useRouter } from 'vue-router';

export default defineComponent({
  name: 'GameNav',
  
  setup() {
    const router = useRouter();
    const isExpanded = ref(false);
    
    const toggleNav = () => {
      isExpanded.value = !isExpanded.value;
    };
    
    const navigateTo = (path: string) => {
      router.push(path);
      isExpanded.value = false;
    };
    
    return {
      isExpanded,
      toggleNav,
      navigateTo
    };
  }
});
</script>

<style scoped>
.game-nav {
  position: fixed;
  right: -280px;
  top: 0;
  bottom: 0;
  width: 280px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  transition: right 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.game-nav.nav-expanded {
  right: 0;
}

.nav-toggle {
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: #4CAF50;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px 0 0 8px;
}

.toggle-icon {
  font-size: 24px;
}

.nav-content {
  padding: 20px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section h3 {
  font-size: 16px;
  color: #333;
  margin-bottom: 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}

.nav-section button {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 8px;
  border: none;
  border-radius: 6px;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

.nav-section button:hover {
  background: #e0e0e0;
  transform: translateX(4px);
}

.nav-section .icon {
  font-size: 20px;
  margin-right: 8px;
}

.nav-section .text {
  font-size: 14px;
}

/* 适配移动端 */
@media (max-width: 768px) {
  .game-nav {
    width: 240px;
    right: -240px;
  }
  
  .nav-section button {
    padding: 10px;
  }
  
  .nav-section .icon {
    font-size: 18px;
  }
  
  .nav-section .text {
    font-size: 13px;
  }
}
</style> 